class TextimagesController < ApplicationController
  
  before_filter :authenticate
  
  def index
    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @devmanagers }
    end
  end
   
  def create
    @page = Page.find(params[:page_id])
    @textimage = @page.textimages.create(params[:textimage])
       
    if @textimage.save
      flash[:notice] = 'Image successfully created.'
      redirect_to(@page.getUrl)
    else
      flash[:notice] = 'Image creation failed.'
      redirect_to ("/index.html")  
    end
  end

  # PUT /pages/1
  # PUT /pages/1.xml
  def update
    @page = Page.find(params[:id])

    respond_to do |format|
      if @page.update_attributes(params[:page])
        flash[:notice] = 'Page was successfully updated.'
        format.html { redirect_to(@page.getUrl) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @page.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /pages/1
  # DELETE /pages/1.xml
  def destroy
    @page = Page.find(params[:id])
    @page.destroy

    respond_to do |format|
      flash[:notice] = 'Page was successfully deleted.'
      format.html { redirect_to("/index.html") }
      format.xml  { head :ok }
    end
  end

end